package demo.server.socket;

import java.net.Socket;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import core.server.CoreServer;
import demo.server.model.QueueModel;

public class DemoServer extends CoreServer{
	
	private int port;
	private QueueModel que;
	private Logger logI = LoggerFactory.getLogger("LogInfo");
	private Logger logE = LoggerFactory.getLogger("LogError");
	public DemoServer(int port, QueueModel que){
		this.port = port;
		this.que = que;
	}

	@Override
	public void onCreate() {
		logI.info("Tao server thanh cong");
	}

	@Override
	public void onDisconnect() {
		logI.info("Ngat server thanh cong");
	}

	@Override
	public void onError(Exception e) {
		logE.error("", e);
	}

	@Override
	public void onLoop(Socket clientSocket) {
		DemoHandler demoHandler = new DemoHandler(clientSocket, que);
		demoHandler.run();
	} 

	
	public void run() {
		create(port);
	}
	
}
